#ifndef EVENT_H
#define EVENT_H
#include <pthread.h>
#include <stdint.h>
class UDKEvent {
public:
	enum{
		kWaitSuccess=0,
		kWaitTimeout=-1,		
	};
    /**
     *  Constructor
     */
    UDKEvent(bool bManualReset=false,bool bInitialState=false);

    /**
     *  Destructor
     */
    virtual ~UDKEvent();

	int WaitForEvent(uint64_t milliseconds);
	int SetEvent();
	int ResetEvent();
	//int PulseEvent();

private:
	int DestroyEvent();
	int UnlockedWaitForEvent(uint64_t milliseconds);

	UDKEvent(){}

    /**
     *  Private copy constructor, to prevent tampering.
     */
    UDKEvent(const UDKEvent &m) {};

    /**
     *  Private copy assignment, to prevent tampering.
     */
    UDKEvent &operator=(const UDKEvent &m) {return *(this);};

    /**
     *  Implementation-specific private data.
     */
    bool m_bAutoReset;
	bool m_bState;
	pthread_cond_t CVariable;
	pthread_mutex_t Mutex;
};

#endif//EVENT_H
